package com.c.ctgproject.utils

import android.media.MediaPlayer
import com.c.ctgproject.base.BaseApplication

class MusicUtil {
    companion object {

        private var player: MediaPlayer? = null

        fun play(resId: Int) {
            player?.let {
                it.stop()
                player = null
            }
//            val afd = MyBaseApplication.getContext().resources.openRawResourceFd(resId)
            MyLog.d("推送的音频:$resId")
            player = MediaPlayer.create(BaseApplication.getBaseApplication(), resId)
            player?.start()
        }

        fun stop() {
            player?.stop()
            player?.release()
        }
    }
}